package com.ctshk.sapp.localfun.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.utils.individual.scenic.req.localfun.ProductIncreaseStrategyBatchReq;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.localfun.dto.*;
import com.ctshk.rpc.localfun.req.*;
import com.ctshk.rpc.localfun.service.ILocalFunProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.text.ParseException;
import java.util.List;

/**
 * @Description 当地玩乐-产品中心
 * @Author wansi <gaylen15527491065@yeah.net>
 * @Date 2021/3/24
 */
@RestController
@RequestMapping("/local-fun-product")
@Api(value = "当地玩乐-产品中心",tags = "当地玩乐-产品中心")
public class LocalFunProductController extends BaseController {

    @DubboReference
    ILocalFunProductService localFunProductService;

    @ApiOperation(value="查询产品列表", notes="查询产品列表",tags = "当地玩乐-产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "当地玩乐-产品中心", operDesc = "查询产品列表")
    @PostMapping("/list")
    public Result<PageResponse<LocalFunProductListDTO>> listLocalFunProduct(@RequestBody LocalFunProductListReq LocalFunProductListReq){
        PageResponse<LocalFunProductListDTO> pageResponse= localFunProductService.list(LocalFunProductListReq,getCurrentUser(getRequest()));
        return Result.success(pageResponse);
    }

    @ApiOperation(value="修改推荐状态", notes="是否推荐 0 否 1 是",tags = "当地玩乐-产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "当地玩乐-产品中心", operDesc = "是否推荐 0 否 1 是")
    @PostMapping("/modify-recommend-status")
    public Result  modifyRecommendStatus(@RequestBody LocalFunProductModifyRecommendStatusReq LocalFunProductModifyRecommendStatusReq){
        return  localFunProductService.modifyRecommendStatus(LocalFunProductModifyRecommendStatusReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="产品上架", notes="",tags = "当地玩乐-产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "当地玩乐-产品中心", operDesc = "产品上架")
    @PostMapping("/put-away")
    public Result  putAway(@RequestBody LocalFunProductBatchSaleStrategyReq LocalFunProductBatchSaleStrategyReq){
        return localFunProductService.putAway(LocalFunProductBatchSaleStrategyReq,getCurrentUser(getRequest()));
    }


    @ApiOperation(value = "查询代理商列表", notes = "查询代理商列表", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "挂账额度-查询额度", operDesc = "挂账额度-查询额度")
    @PostMapping("/query-agent-list1")
    public Result<PageResponse<AgentDto>> queryAgentList2(@RequestBody @Valid AgentReq req) {
        return localFunProductService.queryAgentList(req);
    }

    @ApiOperation(value = "查询代理商列表2", notes = "查询代理商列表2", tags="当地玩乐-门票订单")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "挂账额度-查询额度", operDesc = "挂账额度-查询额度")
    @PostMapping("/query-agent-list")
    public Result<List<AgentDto>> queryAgentList(@RequestBody @Valid AgentReq req) {
        return Result.success(localFunProductService.queryAgentList2(req));
    }

    @ApiOperation(value="产品库存详情", notes="",tags = "当地玩乐-产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "门票产品上架", operDesc = "门票产品上架")
    @PostMapping("/stock-detail")
    public Result<LocalFunStockDetailDTO>  stockDetail(@RequestBody LocalFunProductStockDetailReq LocalFunProductBatchSaleStrategyReq){
        return  localFunProductService.stockDetail(LocalFunProductBatchSaleStrategyReq,getCurrentUser(getRequest()));
    }

    @ApiOperation(value="产品上架详情", notes="",tags = "当地玩乐-产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "景点门票详情", operDesc = "景点门票详情")
    @PostMapping("/localFun-detail")
    public Result<LocalFunProductDetailDTO>  LocalFunDetail(@RequestBody LocalFunProductReq LocalFunProductReq) throws ParseException {
        return  localFunProductService.LocalFunProductDetail(LocalFunProductReq);
    }

    @ApiOperation(value="门票产品上架编辑", notes="",tags = "当地玩乐-产品中心")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "门票产品上架", operDesc = "门票产品上架")
    @PostMapping("/localFun-edit-detail")
    public Result<List<LocalFunProductSaleStrategyDTO>>  LocalFunEdit(@RequestBody LocalFunProductEditReq LocalFunProductEditReq){
        return  localFunProductService.LocalFunProductEditDetai(LocalFunProductEditReq);
    }
}
